package cn.tedu.demo.controller;


import cn.tedu.demo.entity.Sku;
import cn.tedu.demo.mapper.SkuMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/sku")
public class SkuController {
    //注解自动装配
    @Autowired
    private SkuMapper mapper;


    @RequestMapping("/insert")
    public void insert(@RequestBody Sku sku){
        //调用mapper的insert方法
        mapper.insert(sku);
    }

    @RequestMapping("/select")
    public List<Sku> select(){
        //调用mapper的select方法
        return mapper.select();
    }

    @RequestMapping("/selectBySkuName")
    public Sku selectBySkuName(String skuname){
        return mapper.selectBySkuName(skuname);
    }

    @RequestMapping("/delete")
    public void delete(String skuname){
        //调用mapper的delete方法
        mapper.deleteBySkuName(skuname);
    }



}
